package com.summer_administration.mapper;

import com.summer_administration.pojo.Publicity;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface PublicityMapper {
    @Select("<script>" +
            "SELECT * FROM publicity " +
            "WHERE create_user = #{userId} " +
            "</script>")
    List<Publicity> list(Integer userId);

    @Update("UPDATE publicity SET " +
            "commune = #{commune}, " +
            "group_name = #{groupName}, " +
            "picture = #{picture}, " +
            "link = #{link}, " +
            "update_time = #{updateTime} " +
            "WHERE id = #{id}")
    void update(Publicity publicity);

    @Delete("DELETE FROM publicity WHERE id = #{id}")
    void delete(Integer id);

    @Select("SELECT * FROM publicity WHERE id = #{id}")
    Publicity getById(Integer id);

    @Insert("INSERT INTO publicity(commune,group_id,group_name, picture, link, create_user, create_time, update_time) " +
            "VALUES(#{commune},#{groupId},#{groupName}, #{picture}, #{link}, #{createUser}, #{createTime}, #{updateTime})")
    void add(Publicity publicity);
}
